package com.wmcsk;

import android.content.Context;

import com.wmcsk.dl.util.LogUtils;
import com.wmcsk.interfaces.InitResultListener;
import com.wmcsk.interfaces.KuaiyanMenuSdkInterface;
import com.wmcsk.interfaces.MenuAddListener;

/**
 * Created by wm on 2017/12/27.
 */

public class KuaiyanMenuWealSdk implements KuaiyanMenuSdkInterface{
    private static KuaiyanMenuWealSdk kuaiyanMenuWealSdk;
    public static final String ERROR_TAG = "KuaiyanMenuWealSdk";
    private KuaiyanMenuWealSdk(){

    }
    private KuaiyanMenuSdkInterface kuaiyanMenuSdkInterface;
    public void initKYSdkInterface(KuaiyanMenuSdkInterface kuaiyanMenuSdkInterface){
        this.kuaiyanMenuSdkInterface = kuaiyanMenuSdkInterface;
    }
    public static KuaiyanMenuWealSdk getInstance(){
        if(kuaiyanMenuWealSdk == null){
            synchronized (KuaiyanSdk.class){
                if(kuaiyanMenuWealSdk == null){
                    kuaiyanMenuWealSdk = new KuaiyanMenuWealSdk();
                }
            }
        }
        return kuaiyanMenuWealSdk;
    }
    @Override
    public String getVersion() {
        if(kuaiyanMenuSdkInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return "null";
        }
        return kuaiyanMenuSdkInterface.getVersion();
    }

    @Override
    public void init(Context context, InitResultListener initResultListener) {
        if(kuaiyanMenuSdkInterface == null) {
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            if(initResultListener!=null){
                initResultListener.initResult(-10);
            }
            return;
        }
        kuaiyanMenuSdkInterface.init(context,initResultListener);
    }

    @Override
    public String getSdkInfo() {
        if(kuaiyanMenuSdkInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return "null";
        }
        return kuaiyanMenuSdkInterface.getSdkInfo();
    }

    @Override
    public void addMenuLayout(Context context, MenuAddListener menuAddListener) {
        if(kuaiyanMenuSdkInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            if(menuAddListener!=null){
                menuAddListener.loadError(-10,"初始化未完成",new RuntimeException("初始化未完成"));
            }
            return;
        }
        kuaiyanMenuSdkInterface.addMenuLayout(context,menuAddListener);
    }
}
